
//——————————登录__________________________________
$(function () {

    var $btn = $(".Btn1")

    $btn.click(function (e) {
        e.preventDefault();

        var $username = $("#username1");
        var $password = $("#password1");
        $.ajax({
            type: "POST",
            url: "http://localhost/login.php",
            data: {
                username: $username.val(),
                password: $password.val()
            },
            dataType: "json",
            success: function (response) {
                console.log(response)
                console.log(response.type);
                alert("恭喜您登录成功");
                location.href="http://127.0.0.1:5500/dist/index.html";
            }
        });

    });
})

//——————————注册_____________________________________
$(function () {

    var $btn = $(".Btn2")

    $btn.click(function (e) {
        e.preventDefault();

        var $username = $("#username2");
        var $password = $("#password2");
        $.ajax({
            type: "POST",
            url: "http://localhost/register.php",
            data: {
                username: $username.val(),
                password: $password.val()
            },
            dataType: "json",
            success: function (response) {
                console.log(response)
                console.log(response.type);
                alert("恭喜您注册成功，请登录");
            }
        });
    });
})

